<html>
 <head>
  <meta charset="utf-8"/>
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"/>
  <title>
   关于Andrew Ng『应用机器学习的建议』的学习笔记  | 数螺 | NAUT IDEA
  </title>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" rel="stylesheet"/>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
  <style type="text/css">
   #xmain img {
                  max-width: 100%;
                  display: block;
                  margin-top: 10px;
                  margin-bottom: 10px;
                }

                #xmain p {
                    line-height:150%;
                    font-size: 16px;
                    margin-top: 20px;
                }

                #xmain h2 {
                    font-size: 24px;
                }

                #xmain h3 {
                    font-size: 20px;
                }

                #xmain h4 {
                    font-size: 18px;
                }


                .header {
	           background-color: #0099ff;
	           color: #ffffff;
	           margin-bottom: 20px;
	        }

	        .header p {
                  margin: 0px;
                  padding: 10px 0;
                  display: inline-block;  
                  vertical-align: middle;
                  font-size: 16px;
               }

               .header a {
                 color: white;
               }

              .header img {
                 height: 25px;
              }
  </style>
  <script src="http://cdn.bootcss.com/jquery/3.0.0/jquery.min.js">
  </script>
  <script src="http://nautstatic-10007657.file.myqcloud.com/static/css/readability.min.js" type="text/javascript">
  </script>
  <script type="text/javascript">
   $(document).ready(function() {
                 var loc = document.location;
                 var uri = {
                  spec: "http://dataunion.org/14308.html",
                  host: "http://dataunion.org",
                  prePath: "http://dataunion.org",
                  scheme: "http",
                  pathBase: "http://dataunion.org/"
                 };
    
                 var documentClone = document.cloneNode(true);
                 var article = new Readability(uri, documentClone).parse();
     
                 document.getElementById("xmain").innerHTML = article.content;
                });
  </script>
  <!-- 1466457234: Accept with keywords: (title(0.0):建议,数盟,笔记,社区, topn(0.5):社区,离群点,流程,个数,数盟,笔记,分类器,类别,特征,模型,维数,例子,可视化,文章,方法,建议,函数,样本,稀疏,问题,拟合,线性,集上,分数,数据,分类,损失,合页,Python,正则).-->
 </head>
 <body onload="">
  <div class="header">
   <div class="container">
    <div class="row">
     <div class="col-xs-6 col-sm-6 text-left">
      <a href="/databee">
       <img src="http://nautidea-10007657.cos.myqcloud.com/logo_white.png"/>
      </a>
      <a href="/databee">
       <p>
        数螺
       </p>
      </a>
     </div>
     <div class="hidden-xs col-sm-6 text-right">
      <p>
       致力于数据科学的推广和知识传播
      </p>
     </div>
    </div>
   </div>
  </div>
  <div class="container text-center">
   <h1>
    关于Andrew Ng『应用机器学习的建议』的学习笔记
   </h1>
  </div>
  <div class="container" id="xmain">
   ﻿﻿
   <title>
    关于Andrew Ng『应用机器学习的建议』的学习笔记 | 数盟社区
   </title>
   <!-- All in One SEO Pack 2.2.7.6.2 by Michael Torbert of Semper Fi Web Design[32,74] -->
   <!-- /all in one seo pack -->
   <!--
<div align="center">
<a href="http://strata.oreilly.com.cn/hadoop-big-data-cn?cmp=mp-data-confreg-home-stcn16_dataunion_pc" target="_blank"><img src="http://dataunion.org/wp-content/uploads/2016/05/stratabj.jpg"/ ></a>
</div>
-->
   <header id="header-web">
    <div class="header-main">
     <hgroup class="logo">
      <h1>
       <a href="http://dataunion.org/" rel="home" title="数盟社区">
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/logo.png"/>
       </a>
      </h1>
     </hgroup>
     <!--logo-->
     <nav class="header-nav">
      <ul class="menu" id="menu-%e4%b8%bb%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-71" id="menu-item-71">
        <a href="http://dataunion.org/category/events" title="events">
         活动
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22457" id="menu-item-22457">
          <a href="http://dataunion.org/2016timeline">
           2016档期
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22459" id="menu-item-22459">
          <a href="http://dataunion.org/category/parterc">
           合作会议
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor current-menu-parent current-post-parent menu-item-has-children menu-item-20869" id="menu-item-20869">
        <a href="http://dataunion.org/category/tech" title="articles">
         文章
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20867" id="menu-item-20867">
          <a href="http://dataunion.org/category/tech/base" title="base">
           基础架构
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3302" id="menu-item-3302">
          <a href="http://dataunion.org/category/tech/ai" title="ai">
           人工智能
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3303" id="menu-item-3303">
          <a href="http://dataunion.org/category/tech/analysis" title="analysis">
           数据分析
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21920" id="menu-item-21920">
          <a href="http://dataunion.org/category/tech/dm">
           数据挖掘
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3314" id="menu-item-3314">
          <a href="http://dataunion.org/category/tech/viz" title="viz">
           可视化
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3305" id="menu-item-3305">
          <a href="http://dataunion.org/category/tech/devl" title="devl">
           编程语言
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-20876" id="menu-item-20876">
        <a href="http://dataunion.org/category/industry">
         行业
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-16328" id="menu-item-16328">
          <a href="http://dataunion.org/category/industry/case" title="case">
           行业应用
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-2112" id="menu-item-2112">
          <a href="http://dataunion.org/category/industry/demo" title="demo">
           Demo展示
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21562" id="menu-item-21562">
          <a href="http://dataunion.org/category/industry/news">
           行业资讯
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-311" id="menu-item-311">
        <a href="http://dataunion.org/category/sources" title="sources">
         资源
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20870" id="menu-item-20870">
        <a href="http://dataunion.org/category/books" title="book">
         图书
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21363" id="menu-item-21363">
        <a href="http://dataunion.org/category/training">
         课程
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-21853" id="menu-item-21853">
        <a href="http://dataunion.org/category/jobs">
         职位
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22050" id="menu-item-22050">
          <a href="http://dataunion.org/category/career">
           职业规划
          </a>
         </li>
        </ul>
       </li>
      </ul>
     </nav>
     <!--header-nav-->
    </div>
   </header>
   <!--header-web-->
   <div id="main">
    <div id="soutab">
     <form action="http://dataunion.org/" class="search" method="get">
     </form>
    </div>
    <div id="container">
     <nav id="mbx">
      当前位置：
      <a href="http://dataunion.org">
       首页
      </a>
      &gt;
      <a href="http://dataunion.org/category/tech">
       文章
      </a>
      &gt;  正文
     </nav>
     <!--mbx-->
     <article class="content">
      <header align="centre" class="contenttitle">
       <div class="mscc">
        <h1 class="mscctitle">
         <a href="http://dataunion.org/14308.html">
          关于Andrew Ng『应用机器学习的建议』的学习笔记
         </a>
        </h1>
        <address class="msccaddress ">
         <em>
          3,466 次阅读 -
         </em>
         <a href="http://dataunion.org/category/tech" rel="category tag">
          文章
         </a>
        </address>
       </div>
      </header>
      <div class="content-text">
       <p>
        这篇文章是以Bremen大学机器学习课程的教程为基础的。本文总结了使用机器学习解决新问题的一些建议。包括：
       </p>
       <ul>
        <li>
         可视化数据的方法
        </li>
        <li>
         选择一个适合当前问题的机器学习方法
        </li>
        <li>
         鉴别和解决过拟合和欠拟合问题
        </li>
        <li>
         处理大数据库问题（注意：不是非常小的）
        </li>
        <li>
         不同损失函数的利弊
        </li>
       </ul>
       <p>
        本文以Andrew Ng的《应用机器学习的建议 | Advice for applying Machine Learning》为基础。这个笔记的目的是用一个互动的方法解释这些观点。有些建议是可以讨论的。它们仅是建议，不是严格的规则。
       </p>
       <p>
        In [1]:
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a198744450829" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          import time
import numpy as np
np.random.seed(0)
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a198744450829-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a198744450829-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a198744450829-3">
               3
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a198744450829-1">
               <span class="crayon-e">
                import
               </span>
               <span class="crayon-e">
                time
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a198744450829-2">
               <span class="crayon-e">
                import
               </span>
               <span class="crayon-e">
                numpy
               </span>
               <span class="crayon-st">
                as
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                np
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a198744450829-3">
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                random
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                seed
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0109 seconds] -->
       <p>
        In [2]:
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a1a6519063922" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a1a6519063922-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1a6519063922-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1a6519063922-3">
               3
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a1a6519063922-1">
               <span class="crayon-e">
                import
               </span>
               <span class="crayon-v">
                matplotlib
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                pyplot
               </span>
               <span class="crayon-st">
                as
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                plt
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1a6519063922-2">
               <span class="crayon-e">
                import
               </span>
               <span class="crayon-e">
                seaborn
               </span>
               <span class="crayon-st">
                as
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                sns
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1a6519063922-3">
               <span class="crayon-o">
                %
               </span>
               <span class="crayon-e">
                matplotlib
               </span>
               <span class="crayon-v">
                inline
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0100 seconds] -->
       <p>
        In [3] :
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a1ac409044302" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          #Modified from http://scikit-learn.org/stable/auto_examples/plot_learning_curve.html

From sklearn.learning_curve import learning_curve
Def plot_learning_curve(estimator, title, x, ylim=None, cv=None, train_sizes=np.linspace(.1,1.0,5)):
Generate a simple plot of the test and train learning curve.
Parameters
----------------
estimator:object type that implements the “fit” and “predict” methods
An object of that type which is cloned for each validation.

title : string
Title for the chart.

x : array-like, shape(n_samples, n_features)
Training vector, where n_samples is the number of samples and n_features is the number of features

y : array-like, shape (n_samples) or (n_samples, n_features)
Target relative to X for classification or regression;
None for unsupervised learning.

ylim : tuple, shape(ymin, ymax), optional
Defines minimum and maximum yvalues plotted.

cv : integer, cross-validation generator, optional
If an integer is passed, it is the number of folds (defaults to 3).
Specific cross-validation objects can be passed, see sklearn.cross_validation module for the list of possible objects
‘’’’’’

plt.figure()
train_sizes, train_scores, test_scores = learning_curve(estimator, X, y, cv=5, n_jobs=1, train_sizes = train_sizes)
train_scores_mean = np.mean(train_scores, axis = 1)
train_scores_std = np.std(train_scores, axis = 1)
test_scores_mean = np.mean(test_scores, axis = 1)
test_scores_std = np.std(test_scores, axis = 1)

plt.fill_between(train_sizes, train_scores_mean – train_scores_std, train_scores_mean + train_scores_std, alpha = 0.1, color = “r”)
plt.fill_between(train_sizes, test_scores_mean – test_scores_std, test_scores_mean + test_scores_std, alpha = 0.1, color = “g”)
plt.plot(train_szies, train_scores_mean, ‘o-’, color = “r”, label = “Training score”)
plt.plot(train_szies, test_scores_mean, ‘o-’, color = “g”, label = “Cross-validation score”)
plt.xlabel(“Training examples”)
plt.ylabel(“Score”)
plt.legend(loc=”best”)
plt.grid(“on”)
if ylim:
plt.ylim(ylim)
plt.title(title)
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a1ac409044302-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1ac409044302-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1ac409044302-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1ac409044302-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1ac409044302-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1ac409044302-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1ac409044302-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1ac409044302-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1ac409044302-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1ac409044302-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1ac409044302-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1ac409044302-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1ac409044302-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1ac409044302-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1ac409044302-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1ac409044302-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1ac409044302-17">
               17
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1ac409044302-18">
               18
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1ac409044302-19">
               19
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1ac409044302-20">
               20
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1ac409044302-21">
               21
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1ac409044302-22">
               22
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1ac409044302-23">
               23
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1ac409044302-24">
               24
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1ac409044302-25">
               25
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1ac409044302-26">
               26
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1ac409044302-27">
               27
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1ac409044302-28">
               28
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1ac409044302-29">
               29
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1ac409044302-30">
               30
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1ac409044302-31">
               31
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1ac409044302-32">
               32
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1ac409044302-33">
               33
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1ac409044302-34">
               34
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1ac409044302-35">
               35
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1ac409044302-36">
               36
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1ac409044302-37">
               37
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1ac409044302-38">
               38
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1ac409044302-39">
               39
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1ac409044302-40">
               40
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1ac409044302-41">
               41
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1ac409044302-42">
               42
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1ac409044302-43">
               43
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1ac409044302-44">
               44
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1ac409044302-45">
               45
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1ac409044302-46">
               46
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a1ac409044302-1">
               <span class="crayon-p">
                #Modified from http://scikit-learn.org/stable/auto_examples/plot_learning_curve.html
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1ac409044302-2">
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1ac409044302-3">
               <span class="crayon-e">
                From
               </span>
               <span class="crayon-v">
                sklearn
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                learning_curve
               </span>
               <span class="crayon-e">
                import
               </span>
               <span class="crayon-e">
                learning_curve
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1ac409044302-4">
               <span class="crayon-e">
                Def
               </span>
               <span class="crayon-e">
                plot_learning_curve
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                estimator
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                title
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                x
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                ylim
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-v">
                None
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                cv
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-v">
                None
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                train_sizes
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                linspace
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-cn">
                1.0
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-cn">
                5
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-o">
                :
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1ac409044302-5">
               <span class="crayon-i">
                Generate
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-i">
                a
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                simple
               </span>
               <span class="crayon-e">
                plot
               </span>
               <span class="crayon-e">
                of
               </span>
               <span class="crayon-e">
                the
               </span>
               <span class="crayon-e">
                test
               </span>
               <span class="crayon-st">
                and
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                train
               </span>
               <span class="crayon-e">
                learning
               </span>
               <span class="crayon-v">
                curve
               </span>
               <span class="crayon-sy">
                .
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1ac409044302-6">
               <span class="crayon-v">
                Parameters
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1ac409044302-7">
               <span class="crayon-o">
                --
               </span>
               <span class="crayon-o">
                --
               </span>
               <span class="crayon-o">
                --
               </span>
               <span class="crayon-o">
                --
               </span>
               <span class="crayon-o">
                --
               </span>
               <span class="crayon-o">
                --
               </span>
               <span class="crayon-o">
                --
               </span>
               <span class="crayon-o">
                --
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1ac409044302-8">
               <span class="crayon-v">
                estimator
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-t">
                object
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                type
               </span>
               <span class="crayon-e">
                that
               </span>
               <span class="crayon-r">
                implements
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-i">
                the
               </span>
               <span class="crayon-h">
               </span>
               “
               <span class="crayon-i">
                fit
               </span>
               ”
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                and
               </span>
               <span class="crayon-h">
               </span>
               “
               <span class="crayon-i">
                predict
               </span>
               ”
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                methods
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1ac409044302-9">
               <span class="crayon-e">
                An
               </span>
               <span class="crayon-t">
                object
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                of
               </span>
               <span class="crayon-e">
                that
               </span>
               <span class="crayon-e">
                type
               </span>
               <span class="crayon-e">
                which
               </span>
               <span class="crayon-st">
                is
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                cloned
               </span>
               <span class="crayon-st">
                for
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                each
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                validation
               </span>
               <span class="crayon-sy">
                .
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1ac409044302-10">
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1ac409044302-11">
               <span class="crayon-v">
                title
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                string
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1ac409044302-12">
               <span class="crayon-e">
                Title
               </span>
               <span class="crayon-st">
                for
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                the
               </span>
               <span class="crayon-v">
                chart
               </span>
               <span class="crayon-sy">
                .
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1ac409044302-13">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1ac409044302-14">
               <span class="crayon-v">
                x
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                array
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-v">
                like
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                shape
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                n_samples
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                n_features
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1ac409044302-15">
               <span class="crayon-e">
                Training
               </span>
               <span class="crayon-v">
                vector
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                where
               </span>
               <span class="crayon-e">
                n_samples
               </span>
               <span class="crayon-st">
                is
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                the
               </span>
               <span class="crayon-e">
                number
               </span>
               <span class="crayon-e">
                of
               </span>
               <span class="crayon-e">
                samples
               </span>
               <span class="crayon-st">
                and
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                n_features
               </span>
               <span class="crayon-st">
                is
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                the
               </span>
               <span class="crayon-e">
                number
               </span>
               <span class="crayon-e">
                of
               </span>
               <span class="crayon-i">
                features
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1ac409044302-16">
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1ac409044302-17">
               <span class="crayon-v">
                y
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                array
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-v">
                like
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                shape
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                n_samples
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                or
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                n_samples
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                n_features
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1ac409044302-18">
               <span class="crayon-e">
                Target
               </span>
               <span class="crayon-e">
                relative
               </span>
               <span class="crayon-st">
                to
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-i">
                X
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                for
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                classification
               </span>
               <span class="crayon-st">
                or
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                regression
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1ac409044302-19">
               <span class="crayon-e">
                None
               </span>
               <span class="crayon-st">
                for
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                unsupervised
               </span>
               <span class="crayon-v">
                learning
               </span>
               <span class="crayon-sy">
                .
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1ac409044302-20">
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1ac409044302-21">
               <span class="crayon-v">
                ylim
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                tuple
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                shape
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                ymin
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                ymax
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                optional
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1ac409044302-22">
               <span class="crayon-e">
                Defines
               </span>
               <span class="crayon-e">
                minimum
               </span>
               <span class="crayon-st">
                and
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                maximum
               </span>
               <span class="crayon-e">
                yvalues
               </span>
               <span class="crayon-v">
                plotted
               </span>
               <span class="crayon-sy">
                .
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1ac409044302-23">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1ac409044302-24">
               <span class="crayon-v">
                cv
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                integer
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                cross
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-e">
                validation
               </span>
               <span class="crayon-v">
                generator
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                optional
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1ac409044302-25">
               <span class="crayon-st">
                If
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                an
               </span>
               <span class="crayon-t">
                integer
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                is
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                passed
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                it
               </span>
               <span class="crayon-st">
                is
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                the
               </span>
               <span class="crayon-e">
                number
               </span>
               <span class="crayon-e">
                of
               </span>
               <span class="crayon-e">
                folds
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                defaults
               </span>
               <span class="crayon-st">
                to
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                3
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                .
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1ac409044302-26">
               <span class="crayon-e">
                Specific
               </span>
               <span class="crayon-v">
                cross
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-e">
                validation
               </span>
               <span class="crayon-e">
                objects
               </span>
               <span class="crayon-e">
                can
               </span>
               <span class="crayon-e">
                be
               </span>
               <span class="crayon-v">
                passed
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                see
               </span>
               <span class="crayon-v">
                sklearn
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                cross_validation
               </span>
               <span class="crayon-e">
                module
               </span>
               <span class="crayon-st">
                for
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                the
               </span>
               <span class="crayon-e">
                list
               </span>
               <span class="crayon-e">
                of
               </span>
               <span class="crayon-e">
                possible
               </span>
               <span class="crayon-i">
                objects
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1ac409044302-27">
               ‘’’’’’
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1ac409044302-28">
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1ac409044302-29">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                figure
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1ac409044302-30">
               <span class="crayon-v">
                train_sizes
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                train_scores
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                test_scores
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                learning_curve
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                estimator
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                y
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                cv
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                5
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                n_jobs
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                train_sizes
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                train_sizes
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1ac409044302-31">
               <span class="crayon-v">
                train_scores_mean
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                mean
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                train_scores
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                axis
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1ac409044302-32">
               <span class="crayon-v">
                train_scores_std
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                std
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                train_scores
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                axis
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1ac409044302-33">
               <span class="crayon-v">
                test_scores_mean
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                mean
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                test_scores
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                axis
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1ac409044302-34">
               <span class="crayon-v">
                test_scores_std
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                std
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                test_scores
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                axis
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1ac409044302-35">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1ac409044302-36">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                fill_between
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                train_sizes
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                train_scores
               </span>
               <span class="crayon-sy">
                _
               </span>
               mean
               <span class="crayon-h">
               </span>
               –
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                train_scores_std
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                train_scores_mean
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                train_scores_std
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                alpha
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.1
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                color
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               “
               <span class="crayon-i">
                r
               </span>
               ”
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1ac409044302-37">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                fill_between
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                train_sizes
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                test_scores
               </span>
               <span class="crayon-sy">
                _
               </span>
               mean
               <span class="crayon-h">
               </span>
               –
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                test_scores_std
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                test_scores_mean
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                test_scores_std
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                alpha
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.1
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                color
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               “
               <span class="crayon-i">
                g
               </span>
               ”
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1ac409044302-38">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                plot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                train_szies
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                train_scores_mean
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               ‘
               <span class="crayon-v">
                o
               </span>
               <span class="crayon-o">
                -
               </span>
               ’
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                color
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               “
               <span class="crayon-i">
                r
               </span>
               ”
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                label
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               “
               <span class="crayon-e">
                Training
               </span>
               <span class="crayon-i">
                score
               </span>
               ”
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1ac409044302-39">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                plot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                train_szies
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                test_scores_mean
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               ‘
               <span class="crayon-v">
                o
               </span>
               <span class="crayon-o">
                -
               </span>
               ’
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                color
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               “
               <span class="crayon-i">
                g
               </span>
               ”
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                label
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               “
               <span class="crayon-v">
                Cross
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-e">
                validation
               </span>
               <span class="crayon-i">
                score
               </span>
               ”
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1ac409044302-40">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                xlabel
               </span>
               <span class="crayon-sy">
                (
               </span>
               “
               <span class="crayon-e">
                Training
               </span>
               <span class="crayon-i">
                examples
               </span>
               ”
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1ac409044302-41">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                ylabel
               </span>
               <span class="crayon-sy">
                (
               </span>
               “
               <span class="crayon-i">
                Score
               </span>
               ”
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1ac409044302-42">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                legend
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                loc
               </span>
               <span class="crayon-o">
                =
               </span>
               ”
               <span class="crayon-i">
                best
               </span>
               ”
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1ac409044302-43">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                grid
               </span>
               <span class="crayon-sy">
                (
               </span>
               “
               <span class="crayon-i">
                on
               </span>
               ”
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1ac409044302-44">
               <span class="crayon-st">
                if
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                ylim
               </span>
               <span class="crayon-o">
                :
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1ac409044302-45">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                ylim
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                ylim
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1ac409044302-46">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                title
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                title
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0928 seconds] -->
       <p>
       </p>
       <h2>
        数据集
       </h2>
       <p>
        我们使用sklearn的make_classification函数来生成一些简单的玩具数据：
       </p>
       <p>
        In [4] :
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a1b4210670403" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          from sklearn.datasets import make_classification
X, y = make_classification(1000, n_features=20, n_informative=2, 
                           n_redundant=2, n_classes=2, random_state=0)

from pandas import DataFrame
df = DataFrame(np.hstack((X, y[:, None])), 
               columns = range(20) + ["class"])
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a1b4210670403-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1b4210670403-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1b4210670403-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1b4210670403-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1b4210670403-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1b4210670403-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1b4210670403-7">
               7
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a1b4210670403-1">
               <span class="crayon-e">
                from
               </span>
               <span class="crayon-v">
                sklearn
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                datasets
               </span>
               <span class="crayon-e">
                import
               </span>
               <span class="crayon-v">
                make
               </span>
               <span class="crayon-sy">
                _
               </span>
               classification
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1b4210670403-2">
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                y
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                make_classification
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                1000
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                n_features
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                20
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                n_informative
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1b4210670403-3">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                n_redundant
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                n_classes
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                random_state
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1b4210670403-4">
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1b4210670403-5">
               <span class="crayon-e">
                from
               </span>
               <span class="crayon-e">
                pandas
               </span>
               <span class="crayon-e">
                import
               </span>
               <span class="crayon-e">
                DataFrame
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1b4210670403-6">
               <span class="crayon-v">
                df
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                DataFrame
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                hstack
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                y
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                None
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1b4210670403-7">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                columns
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                range
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                20
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-s">
                "class"
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0117 seconds] -->
       <p>
        注意到我们为二分类生成了一个数据集，这个数据集包括1000个数据点，每个特征20维。我们已经使用pandas的DataFrame类把数据和类别封装到一个共同的数据结构中。我们来看一看前5个数据点：
       </p>
       <p>
        In [5]:
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a1bb482351457" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          df[:5]
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a1bb482351457-1">
               1
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a1bb482351457-1">
               <span class="crayon-v">
                df
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-cn">
                5
               </span>
               <span class="crayon-sy">
                ]
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0007 seconds] -->
       <p>
        Out[5]:
        <code>
         <br/>
        </code>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a1c1052470608" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          0 1 2 3 4 5 6 7 8 9 ... 11 12 13 14 15 16 17 18 19 class
0 -1.063780 0.676409 1.069356 -0.217580 0.460215 -0.399167 -0.079188 1.209385 -0.785315 -0.172186 ... -0.993119 0.306935 0.064058 -1.054233 -0.527496 -0.074183 -0.355628 1.057214 -0.902592 0
1 0.070848 -1.695281 2.449449 -0.530494 -0.932962 2.865204 2.435729 -1.618500 1.300717 0.348402 ... 0.225324 0.605563 -0.192101 -0.068027 0.971681 -1.792048 0.017083 -0.375669 -0.623236 1
2 0.940284 -0.492146 0.677956 -0.227754 1.401753 1.231653 -0.777464 0.015616 1.331713 1.084773 ... -0.050120 0.948386 -0.173428 -0.477672 0.760896 1.001158 -0.069464 1.359046 -1.189590 1
3 -0.299517 0.759890 0.182803 -1.550233 0.338218 0.363241 -2.100525 -0.438068 -0.166393 -0.340835 ... 1.178724 2.831480 0.142414 -0.202819 2.405715 0.313305 0.404356 -0.287546 -2.847803 1
4 -2.630627 0.231034 0.042463 0.478851 1.546742 1.637956 -1.532072 -0.734445 0.465855 0.473836 ... -1.061194 -0.888880 1.238409 -0.572829 -1.275339 1.003007 -0.477128 0.098536 0.527804 0
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a1c1052470608-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1c1052470608-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1c1052470608-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1c1052470608-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1c1052470608-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1c1052470608-6">
               6
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a1c1052470608-1">
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                3
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                4
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                5
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                6
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                7
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                8
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                9
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                11
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                12
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                13
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                14
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                15
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                16
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                17
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                18
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                19
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                class
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1c1052470608-2">
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                1.063780
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.676409
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1.069356
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.217580
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.460215
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.399167
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.079188
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1.209385
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.785315
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.172186
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.993119
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.306935
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.064058
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                1.054233
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.527496
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.074183
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.355628
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1.057214
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.902592
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1c1052470608-3">
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.070848
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                1.695281
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                2.449449
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.530494
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.932962
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                2.865204
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                2.435729
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                1.618500
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1.300717
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.348402
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.225324
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.605563
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.192101
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.068027
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.971681
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                1.792048
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.017083
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.375669
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.623236
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1c1052470608-4">
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.940284
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.492146
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.677956
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.227754
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1.401753
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1.231653
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.777464
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.015616
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1.331713
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1.084773
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.050120
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.948386
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.173428
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.477672
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.760896
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1.001158
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.069464
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1.359046
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                1.189590
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1c1052470608-5">
               <span class="crayon-cn">
                3
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.299517
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.759890
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.182803
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                1.550233
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.338218
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.363241
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                2.100525
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.438068
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.166393
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.340835
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1.178724
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                2.831480
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.142414
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.202819
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                2.405715
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.313305
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.404356
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.287546
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                2.847803
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1c1052470608-6">
               <span class="crayon-cn">
                4
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                2.630627
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.231034
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.042463
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.478851
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1.546742
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1.637956
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                1.532072
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.734445
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.465855
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.473836
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                1.061194
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.888880
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1.238409
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.572829
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                1.275339
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1.003007
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.477128
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.098536
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.527804
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0366 seconds] -->
       <p>
        通过直接查看原始特征值，我们很难获得该问题的任何线索，即使在这个低维的例子中。因此，有很多的提供数据的更容易视图的方法；其中的小部分将在接下来的部分中讨论。
       </p>
       <h2>
        可视化
       </h2>
       <p>
        当你接到一个新的问题，第一步几乎都是可视化，也就是说，观察你的数据。
       </p>
       <p>
        Seaborn是一个不错的统计数据可视化包。我们使用它的一些函数来探索数据。
       </p>
       <p>
        第一步是使用pairplot生成散点图和直方图。两种颜色对应了两个类别，我们使用了特征的一个子集、仅仅使用前50个数据点来简化问题。
       </p>
       <p>
        In [6] :
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a1c9302457399" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          _ = sns.pairplot(df[:50], vars=[8, 11, 12, 14, 19], hue="class", size=1.5)
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a1c9302457399-1">
               1
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a1c9302457399-1">
               <span class="crayon-v">
                _
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                sns
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                pairplot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                df
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-cn">
                50
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                vars
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-cn">
                8
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                11
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                12
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                14
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                19
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                hue
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "class"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                size
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                1.5
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0086 seconds] -->
       <p>
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebgw1eqtpnsxt9vj20g40es77f.jpg"/>
       </p>
       <p>
        基于该直方图，我们可以看到一些特征比其他特征对分类更有用。特别地，特征11和14看起来有丰富的信息量。这两个特征的散点图显示类别在二维空间中几乎是线性可分的。要更加注意的是，特征12和19是高度负相关的。我们可以通过使用corrplot更系统地探索相关性：
       </p>
       <p>
        In [7] :
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a1cf704068278" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          plt.figure(figsize=(12, 10))
_ = sns.corrplot(df, annot=False)
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a1cf704068278-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1cf704068278-2">
               2
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a1cf704068278-1">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                figure
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                figsize
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                12
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                10
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1cf704068278-2">
               <span class="crayon-v">
                _
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                sns
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                corrplot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                df
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                annot
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-t">
                False
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0095 seconds] -->
       <p>
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebgw1eqtpnsaaijj20hi0fat9l.jpg"/>
       </p>
       <p>
        我们可以发现我们之前的观察结果在这里得到了确认：特征11和14与类强相关（他们有丰富的信息量）。更进一步，特征12和特征19强负相关，特征19和特征14强相关。因此，有一些特征是冗余的。这对于有些分类器可能会出现问题，比如，朴素贝叶斯，它假设所有的特征都是独立的。剩下的特征大部分都是噪声，他们既不相互关联，也不和类别相关。
       </p>
       <p>
        注意到如果特征维数较大、数据点较少的时候，数据可视化会变得更有挑战性。我们在后面会给出一个高维数据可视化的例子。
       </p>
       <h2>
        方法的选择
       </h2>
       <p>
        一旦我们已经使用可视化方法对数据进行了探索，我们就可以开始应用机器学习了。机器学习方法数量众多，通常很难决定先尝试哪种方法。这个简单的备忘单（归功于Andreas Müller和sklearn团队）可以帮助你为你的问题选择一个合适的机器学习方法（供选择的备忘录见
       </p>
       <p>
        http://dlib.net/ml_guide.svg）
       </p>
       <p>
        In [8] :
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a1d6485204371" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          from IPython.display import Image
Image(filename='ml_map.png', width=800, height=600)
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a1d6485204371-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1d6485204371-2">
               2
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a1d6485204371-1">
               <span class="crayon-e">
                from
               </span>
               <span class="crayon-v">
                IPython
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                display
               </span>
               <span class="crayon-e">
                import
               </span>
               <span class="crayon-e">
                Image
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1d6485204371-2">
               <span class="crayon-e">
                Image
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                filename
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                'ml_map.png'
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                width
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                800
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                height
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                600
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0123 seconds] -->
       <p>
        Out[8] :
       </p>
       <p>
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebgw1eqtpnrsfwnj21kw0zgn9e1.jpg"/>
       </p>
       <p>
        我们有了1000个样本，要预测一个类别，并且有了标签，那么备忘单推荐我们首先使用LinearSVC（LinearSVC代表线性核的支持向量分类，并且对于这类特殊问题使用一个有效的算法）。所有我们做了个试验。LinearSVC需要选择正则化；我们使用标准L2范数惩罚和C=10.我们分别画出训练分数和验证分数的学习曲线（这个例子中分数代表准确率）：
       </p>
       <p>
        In [9] :
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a1dd571710630" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          from sklearn.svm import LinearSVC
plot_learning_curve(LinearSVC(C=10.0), "LinearSVC(C=10.0)",
X, y, ylim=(0.8, 1.01),
train_sizes=np.linspace(.05, 0.2, 5))
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a1dd571710630-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1dd571710630-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1dd571710630-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1dd571710630-4">
               4
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a1dd571710630-1">
               <span class="crayon-e">
                from
               </span>
               <span class="crayon-v">
                sklearn
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                svm
               </span>
               <span class="crayon-e">
                import
               </span>
               <span class="crayon-e">
                LinearSVC
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1dd571710630-2">
               <span class="crayon-e">
                plot_learning_curve
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                LinearSVC
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                C
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                10.0
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "LinearSVC(C=10.0)"
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1dd571710630-3">
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                y
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                ylim
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                0.8
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1.01
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1dd571710630-4">
               <span class="crayon-v">
                train_sizes
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                linspace
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-cn">
                05
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.2
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                5
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0021 seconds] -->
       <p>
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebgw1eqtpnqqm57j20b107vgm1.jpg"/>
       </p>
       <p>
        我们可以注意到训练数据和交叉验证数据的错误率有很大的差距。这意味什么？我们可能过度拟合训练数据了！
       </p>
       <h2>
        解决过拟合
       </h2>
       <p>
        有很多方法来减少过拟合：
       </p>
       <ul>
        <li>
         <strong>
          增加训练样本数
         </strong>
        </li>
       </ul>
       <p>
        （获得更多的数据是机器学习从业者的共同愿望）
       </p>
       <p>
        In [10] :
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a1e3043086477" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          plot_learning_curve(LinearSVC(C=10.0), "LinearSVC(C=10.0)",
                    X, y, ylim=(0.8, 1.1),
                    train_sizes=np.linspace(.1, 1.0, 5))
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a1e3043086477-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1e3043086477-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1e3043086477-3">
               3
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a1e3043086477-1">
               <span class="crayon-e">
                plot_learning_curve
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                LinearSVC
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                C
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                10.0
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "LinearSVC(C=10.0)"
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1e3043086477-2">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                y
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                ylim
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                0.8
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1.1
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1e3043086477-3">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                train_sizes
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                linspace
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1.0
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                5
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0020 seconds] -->
       <p>
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebgw1eqtpnq85jgj20b207vt96.jpg"/>
       </p>
       <p>
        可以看到当训练数据增加时，验证分数越来越大，差距越来越小；因此现在不再过拟合了。有很多获得更多数据的方法，比如（a）可以尽力投资收集更多数据，（b）基于现有数据创造一些人为的数据（比如图像旋转，平移，扭曲），或者（c）加入人工噪声。
       </p>
       <p>
        如果以上的这些方法都不可行，就不可能获得更多的数据，我们或者可以
       </p>
       <ul>
        <li>
         <strong>
          减少特征的维数
         </strong>
        </li>
       </ul>
       <p>
        （从我们可视化中可以知道，特征11和14是信息量最大的）
       </p>
       <p>
        In [11] :
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a1ea534817259" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          plot_learning_curve(LinearSVC(C=10.0), "LinearSVC(C=10.0) Features: 11&amp;amp;14",
                    X[:, [11, 14]], y, ylim=(0.8, 1.0),
                    train_sizes=np.linspace(.05, 0.2, 5))
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a1ea534817259-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1ea534817259-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1ea534817259-3">
               3
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a1ea534817259-1">
               <span class="crayon-e">
                plot_learning_curve
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                LinearSVC
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                C
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                10.0
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "LinearSVC(C=10.0) Features: 11&amp;amp;14"
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1ea534817259-2">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-cn">
                11
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                14
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                y
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                ylim
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                0.8
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1.0
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1ea534817259-3">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                train_sizes
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                linspace
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-cn">
                05
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.2
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                5
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0108 seconds] -->
       <p>
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebgw1eqtpnpicavj20b107vjrr.jpg"/>
       </p>
       <p>
        注意到，因为我们是手动的挑选特征，而且在比我们给分类器更多的数据上，这有一点作弊的意味。我们可以使用自动挑选特征：
       </p>
       <p>
        In [12] :
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a1f0736987850" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          from sklearn.pipeline import Pipeline
from sklearn.feature_selection import SelectKBest, f_classif
# SelectKBest(f_classif, k=2) will select the k=2 best features according to their Anova F-value

plot_learning_curve(Pipeline([("fs", SelectKBest(f_classif, k=2)), # select two features
                               ("svc", LinearSVC(C=10.0))]),
                    "SelectKBest(f_classif, k=2) + LinearSVC(C=10.0)",
                    X, y, ylim=(0.8, 1.0),
                    train_sizes=np.linspace(.05, 0.2, 5))
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a1f0736987850-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1f0736987850-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1f0736987850-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1f0736987850-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1f0736987850-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1f0736987850-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1f0736987850-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1f0736987850-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1f0736987850-9">
               9
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a1f0736987850-1">
               <span class="crayon-e">
                from
               </span>
               <span class="crayon-v">
                sklearn
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                pipeline
               </span>
               <span class="crayon-e">
                import
               </span>
               <span class="crayon-e">
                Pipeline
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1f0736987850-2">
               <span class="crayon-e">
                from
               </span>
               <span class="crayon-v">
                sklearn
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                feature_selection
               </span>
               <span class="crayon-e">
                import
               </span>
               <span class="crayon-v">
                SelectKBest
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                f_classif
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1f0736987850-3">
               <span class="crayon-p">
                # SelectKBest(f_classif, k=2) will select the k=2 best features according to their Anova F-value
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1f0736987850-4">
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1f0736987850-5">
               <span class="crayon-e">
                plot_learning_curve
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                Pipeline
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                "fs"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                SelectKBest
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                f_classif
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                k
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-p">
                # select two features
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1f0736987850-6">
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                "svc"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                LinearSVC
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                C
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                10.0
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1f0736987850-7">
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "SelectKBest(f_classif, k=2) + LinearSVC(C=10.0)"
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1f0736987850-8">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                y
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                ylim
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                0.8
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1.0
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1f0736987850-9">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                train_sizes
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                linspace
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-cn">
                05
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.2
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                5
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0058 seconds] -->
       <p>
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebgw1eqtpnp1849j20b107vdg8.jpg"/>
       </p>
       <p>
        这样做效果非常好。在这个toy数据集上，特征选择是简单的。应该注意到特征选择只是减少模型复杂度的一个特殊种类。其他的方法是：（a）减少线性回归多项式模型的次数，（b）减少人工神经网络节点的个数/层数，（c）增加RBF核的带宽等等。
       </p>
       <p>
        仍然有一个问题：为什么分类器不能自动的识别有用的特征？首先让我们转向另一种选择，来减少过拟合：
       </p>
       <ul>
        <li>
         <strong>
          增加分类器的正则化
         </strong>
        </li>
       </ul>
       <p>
        （减少线性SVC的C的系数）
       </p>
       <p>
        In [13] :
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a1f7225308705" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          plot_learning_curve(LinearSVC(C=0.1), "LinearSVC(C=0.1)", 
                    X, y, ylim=(0.8, 1.0),
                    train_sizes=np.linspace(.05, 0.2, 5))
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a1f7225308705-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1f7225308705-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1f7225308705-3">
               3
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a1f7225308705-1">
               <span class="crayon-e">
                plot_learning_curve
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                LinearSVC
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                C
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                0.1
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "LinearSVC(C=0.1)"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1f7225308705-2">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                y
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                ylim
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                0.8
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1.0
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1f7225308705-3">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                train_sizes
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                linspace
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-cn">
                05
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.2
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                5
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0021 seconds] -->
       <p>
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebgw1eqtpnoqurej20b107vjrt.jpg"/>
       </p>
       <p>
        这已经有一点点作用了。我们也可以使用基于交叉验证的网格搜索自动地挑选分类器的正则化：
       </p>
       <p>
        In [14] :
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a1fd282705463" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          from sklearn.grid_search import GridSearchCV
est = GridSearchCV(LinearSVC(), 
                   param_grid={"C": [0.001, 0.01, 0.1, 1.0, 10.0]})
plot_learning_curve(est, "LinearSVC(C=AUTO)", 
                    X, y, ylim=(0.8, 1.0),
                    train_sizes=np.linspace(.05, 0.2, 5))
print "Chosen parameter on 100 datapoints: %s" % est.fit(X[:100], y[:100]).best_params_
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a1fd282705463-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1fd282705463-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1fd282705463-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1fd282705463-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1fd282705463-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a1fd282705463-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a1fd282705463-7">
               7
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a1fd282705463-1">
               <span class="crayon-e">
                from
               </span>
               <span class="crayon-v">
                sklearn
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                grid_search
               </span>
               <span class="crayon-e">
                import
               </span>
               <span class="crayon-e">
                GridSearchCV
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1fd282705463-2">
               <span class="crayon-v">
                est
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                GridSearchCV
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                LinearSVC
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1fd282705463-3">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                param_grid
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-sy">
                {
               </span>
               <span class="crayon-s">
                "C"
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-cn">
                0.001
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.01
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.1
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1.0
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                10.0
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                }
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1fd282705463-4">
               <span class="crayon-e">
                plot_learning_curve
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                est
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "LinearSVC(C=AUTO)"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1fd282705463-5">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                y
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                ylim
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                0.8
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1.0
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a1fd282705463-6">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                train_sizes
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                linspace
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-cn">
                05
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.2
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                5
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a1fd282705463-7">
               <span class="crayon-i">
                print
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "Chosen parameter on 100 datapoints: %s"
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                %
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                est
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                fit
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-cn">
                100
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                y
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-cn">
                100
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                best_params_
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0042 seconds] -->
       <p>
        在100个数据点上选择参数：{‘C’: 0.01}
       </p>
       <p>
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebgw1eqtpnno3z9j20b107vaaj.jpg"/>
       </p>
       <p>
        一般说来，特征选择似乎更好。分类器可以自动识别有用的特征吗？回想一下，LinearSVC还支持L1范数惩罚，这产生了一个稀疏的解决方案。稀疏解决方案对应一个隐式的特征选择。让我们来试试这个：
       </p>
       <p>
        In [15] :
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a204817153003" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          plot_learning_curve(LinearSVC(C=0.1, penalty='l1', dual=False), 
                    "LinearSVC(C=0.1, penalty='l1')", 
                    X, y, ylim=(0.8, 1.0),
                    train_sizes=np.linspace(.05, 0.2, 5))
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a204817153003-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a204817153003-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a204817153003-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a204817153003-4">
               4
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a204817153003-1">
               <span class="crayon-e">
                plot_learning_curve
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                LinearSVC
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                C
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                0.1
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                penalty
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                'l1'
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                dual
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-t">
                False
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a204817153003-2">
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "LinearSVC(C=0.1, penalty='l1')"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a204817153003-3">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                y
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                ylim
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                0.8
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1.0
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a204817153003-4">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                train_sizes
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                linspace
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-cn">
                05
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.2
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                5
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0066 seconds] -->
       <p>
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebgw1eqtpnn38f4j20b107vwev.jpg"/>
       </p>
       <p>
        这看起来也很好。让我们来探讨学到的系数：
       </p>
       <p>
        In [16] :
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a20a678495803" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          est = LinearSVC(C=0.1, penalty='l1', dual=False)
est.fit(X[:150], y[:150])  # fit on 150 datapoints
print "Coefficients learned: %s" % est.coef_
print "Non-zero coefficients: %s" % np.nonzero(est.coef_)[1]
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a20a678495803-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a20a678495803-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a20a678495803-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a20a678495803-4">
               4
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a20a678495803-1">
               <span class="crayon-v">
                est
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                LinearSVC
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                C
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                0.1
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                penalty
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                'l1'
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                dual
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-t">
                False
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a20a678495803-2">
               <span class="crayon-v">
                est
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                fit
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-cn">
                150
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                y
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-cn">
                150
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-p">
                # fit on 150 datapoints
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a20a678495803-3">
               <span class="crayon-i">
                print
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "Coefficients learned: %s"
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                %
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                est
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                coef_
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a20a678495803-4">
               <span class="crayon-i">
                print
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "Non-zero coefficients: %s"
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                %
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                nonzero
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                est
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                coef_
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                ]
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0095 seconds] -->
       <p>
        <code>
         Coefficients learned: [[ 0. 0. 0. 0. 0. 0.01857999
         <br/>
         0. 0. 0. 0.004135 0. 1.05241369
         <br/>
         0.01971419 0. 0. 0. 0. -0.05665314
         <br/>
         0.14106505 0. ]]
         <br/>
         Non-zero coefficients: [ 5 9 11 12 17 18]
        </code>
       </p>
       <p>
        大部分系数是0（对应的特征被忽略），并且目前最大的权重在特征11上。
       </p>
       <h2>
        不同的数据集
       </h2>
       <p>
        我们生成另外一个二分类的数据集，并且再次应用LinearSVC。
       </p>
       <p>
        In [17]:
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a211120921019" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          from sklearn.datasets import make_circles
X, y = make_circles(n_samples=1000, random_state=2)
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a211120921019-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a211120921019-2">
               2
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a211120921019-1">
               <span class="crayon-e">
                from
               </span>
               <span class="crayon-v">
                sklearn
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                datasets
               </span>
               <span class="crayon-e">
                import
               </span>
               <span class="crayon-v">
                make
               </span>
               <span class="crayon-sy">
                _
               </span>
               circles
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a211120921019-2">
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                y
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                make_circles
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                n_samples
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                1000
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                random_state
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0016 seconds] -->
       <p>
        In [18]:
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a217681252383" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          plot_learning_curve(LinearSVC(C=0.25), "LinearSVC(C=0.25)", 
                    X, y, ylim=(0.5, 1.0),
                    train_sizes=np.linspace(.1, 1.0, 5))
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a217681252383-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a217681252383-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a217681252383-3">
               3
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a217681252383-1">
               <span class="crayon-e">
                plot_learning_curve
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                LinearSVC
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                C
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                0.25
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "LinearSVC(C=0.25)"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a217681252383-2">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                y
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                ylim
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                0.5
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1.0
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a217681252383-3">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                train_sizes
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                linspace
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1.0
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                5
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0022 seconds] -->
       <p>
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebgw1eqtpnmf83lj20aw07v74n.jpg"/>
        <br/>
        啊，这非常糟糕，甚至训练误差都不如随机误差。这个可能的原因是什么？难道上面的所有方法（更多数据，特征选择，增加正则化）都不奏效了吗？
       </p>
       <p>
        结果是：No。我们处在一个完全不同的情况：以前，训练分数一直接近完美，我们不得不解决过拟合。这次，训练误差也非常低。是
        <strong>
         欠拟合
        </strong>
        。让我们来看一看数据：
       </p>
       <p>
        In [19] :
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a21d231830223" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          df = DataFrame(np.hstack((X, y[:, None])), 
               columns = range(2) + ["class"])
_ = sns.pairplot(df, vars=[0, 1], hue="class", size=3.5)
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a21d231830223-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a21d231830223-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a21d231830223-3">
               3
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a21d231830223-1">
               <span class="crayon-v">
                df
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                DataFrame
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                hstack
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                y
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                None
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a21d231830223-2">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                columns
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                range
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-s">
                "class"
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a21d231830223-3">
               <span class="crayon-v">
                _
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                sns
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                pairplot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                df
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                vars
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                hue
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "class"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                size
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                3.5
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0029 seconds] -->
       <p>
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebgw1eqtpnlwc0mj20fc0dsmys.jpg"/>
       </p>
       <p>
        这些数据显然不是线性可分的；更多的数据或者更少的特征没有用了。我们的模型错了；因此欠拟合。
       </p>
       <h2>
        解决欠拟合
       </h2>
       <p>
        减少欠拟合的方法：
       </p>
       <ul>
        <li>
         使用更多或更好的特征（到原点的距离应该有用！）
        </li>
       </ul>
       <p>
        In [20] :
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a223893583214" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          # add squared distance from origin as third feature
X_extra = np.hstack((X, X[:, [0]]**2 + X[:, [1]]**2))

plot_learning_curve(LinearSVC(C=0.25), "LinearSVC(C=0.25) + distance feature", 
                    X_extra, y, ylim=(0.5, 1.0),
                    train_sizes=np.linspace(.1, 1.0, 5))
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a223893583214-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a223893583214-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a223893583214-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a223893583214-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a223893583214-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a223893583214-6">
               6
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a223893583214-1">
               <span class="crayon-p">
                # add squared distance from origin as third feature
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a223893583214-2">
               <span class="crayon-v">
                X_extra
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                hstack
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-o">
                *
               </span>
               <span class="crayon-o">
                *
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-o">
                *
               </span>
               <span class="crayon-o">
                *
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a223893583214-3">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a223893583214-4">
               <span class="crayon-e">
                plot_learning_curve
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                LinearSVC
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                C
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                0.25
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "LinearSVC(C=0.25) + distance feature"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a223893583214-5">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                X_extra
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                y
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                ylim
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                0.5
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1.0
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a223893583214-6">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                train_sizes
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                linspace
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1.0
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                5
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0138 seconds] -->
       <p>
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebgw1eqtpnl5bylj20aw07vjro.jpg"/>
       </p>
       <p>
        非常好！但是我们必须要花一些心思来想出这些特征。或许分类器可以自动的做到这些？这需要
       </p>
       <ul>
        <li>
         <strong>
          使用更复杂的模型
         </strong>
        </li>
       </ul>
       <p>
        （减少正则化或非线性核）
       </p>
       <p>
        In [21] :
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a22a926030848" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          from sklearn.svm import SVC
# note: we use the original X without the extra feature
plot_learning_curve(SVC(C=2.5, kernel="rbf", gamma=1.0),
                    "SVC(C=2.5, kernel='rbf', gamma=1.0)",
                    X, y, ylim=(0.5, 1.0), 
                    train_sizes=np.linspace(.1, 1.0, 5))
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a22a926030848-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a22a926030848-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a22a926030848-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a22a926030848-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a22a926030848-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a22a926030848-6">
               6
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a22a926030848-1">
               <span class="crayon-e">
                from
               </span>
               <span class="crayon-v">
                sklearn
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                svm
               </span>
               <span class="crayon-e">
                import
               </span>
               <span class="crayon-v">
                SVC
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a22a926030848-2">
               <span class="crayon-p">
                # note: we use the original X without the extra feature
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a22a926030848-3">
               <span class="crayon-e">
                plot_learning_curve
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                SVC
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                C
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                2.5
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                kernel
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "rbf"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                gamma
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                1.0
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a22a926030848-4">
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "SVC(C=2.5, kernel='rbf', gamma=1.0)"
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a22a926030848-5">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                y
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                ylim
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                0.5
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1.0
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a22a926030848-6">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                train_sizes
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                linspace
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1.0
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                5
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0028 seconds] -->
       <p>
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebgw1eqtpnkl5hdj20aw07vmxg.jpg"/>
       </p>
       <p>
        是的，这也可以达到满意的效果！
       </p>
       <h2>
        更大的数据集和更高维的特征空间
       </h2>
       <p>
        回到原始的数据集上，但是这次有更多的特征和样本，并且有5类。LinearSVC在这样大小的数据集上会有一点慢；备忘单上建议使用SGDClassifier。这个分类器学习到一个线性模型（就像LinearSVC或logistic回归），但是它在训练中使用随机梯度下降（就像反向传播的人工神经网络一样）。
       </p>
       <p>
        SGDClassifier允许小批量扫描数据，这对于数据量太大不能放到内存中时有帮助。交叉验证和这项技术不兼容；使用逐步验证代替：这里，估计器总是在训练数据集的下一块上进行测试（在用它进行训练之前）。训练之后，会再次进行测试来检查它适应数据的能力。
       </p>
       <p>
        In [22] :
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a231277988206" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          X, y = make_classification(200000, n_features=200, n_informative=25, 
                           n_redundant=0, n_classes=10, class_sep=2,
                           random_state=0)
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a231277988206-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a231277988206-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a231277988206-3">
               3
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a231277988206-1">
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                y
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                make_classification
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                200000
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                n_features
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                200
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                n_informative
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                25
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a231277988206-2">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                n_redundant
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                n_classes
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                10
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                class_sep
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a231277988206-3">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                random_state
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0020 seconds] -->
       <p>
        In [23]:
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a237241319345" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          from sklearn.linear_model import SGDClassifier
est = SGDClassifier(penalty="l2", alpha=0.001)
progressive_validation_score = []
train_score = []
for datapoint in range(0, 199000, 1000):
    X_batch = X[datapoint:datapoint+1000]
    y_batch = y[datapoint:datapoint+1000]
    if datapoint &amp;gt; 0:
        progressive_validation_score.append(est.score(X_batch, y_batch))
    est.partial_fit(X_batch, y_batch, classes=range(10))
    if datapoint &amp;gt; 0:
        train_score.append(est.score(X_batch, y_batch))

plt.plot(train_score, label="train score")
plt.plot(progressive_validation_score, label="progressive validation score")
plt.xlabel("Mini-batch")
plt.ylabel("Score")
plt.legend(loc='best')
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a237241319345-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a237241319345-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a237241319345-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a237241319345-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a237241319345-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a237241319345-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a237241319345-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a237241319345-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a237241319345-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a237241319345-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a237241319345-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a237241319345-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a237241319345-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a237241319345-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a237241319345-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a237241319345-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a237241319345-17">
               17
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a237241319345-18">
               18
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a237241319345-1">
               <span class="crayon-e">
                from
               </span>
               <span class="crayon-v">
                sklearn
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                linear_model
               </span>
               <span class="crayon-e">
                import
               </span>
               <span class="crayon-e">
                SGDClassifier
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a237241319345-2">
               <span class="crayon-v">
                est
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                SGDClassifier
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                penalty
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "l2"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                alpha
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                0.001
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a237241319345-3">
               <span class="crayon-v">
                progressive_validation_score
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-sy">
                ]
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a237241319345-4">
               <span class="crayon-v">
                train_score
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-sy">
                ]
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a237241319345-5">
               <span class="crayon-st">
                for
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                datapoint
               </span>
               <span class="crayon-st">
                in
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                range
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                199000
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1000
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-o">
                :
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a237241319345-6">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                X_batch
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-v">
                datapoint
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-v">
                datapoint
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-cn">
                1000
               </span>
               <span class="crayon-sy">
                ]
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a237241319345-7">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                y_batch
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                y
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-v">
                datapoint
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-v">
                datapoint
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-cn">
                1000
               </span>
               <span class="crayon-sy">
                ]
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a237241319345-8">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                if
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                datapoint
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-o">
                :
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a237241319345-9">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                progressive_validation_score
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                append
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                est
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                score
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                X_batch
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                y_batch
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a237241319345-10">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                est
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                partial_fit
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                X_batch
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                y_batch
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                classes
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-e">
                range
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                10
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a237241319345-11">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                if
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                datapoint
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-o">
                :
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a237241319345-12">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                train_score
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                append
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                est
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                score
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                X_batch
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                y_batch
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a237241319345-13">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a237241319345-14">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                plot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                train_score
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                label
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "train score"
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a237241319345-15">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                plot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                progressive_validation_score
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                label
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "progressive validation score"
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a237241319345-16">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                xlabel
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                "Mini-batch"
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a237241319345-17">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                ylabel
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                "Score"
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a237241319345-18">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                legend
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                loc
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                'best'
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0191 seconds] -->
       <p>
        Out[23]:
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a23d158661918" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          &amp;lt;matplotlib.legend.Legend at 0x7f6a24e2dfd0&amp;gt;
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a23d158661918-1">
               1
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a23d158661918-1">
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                lt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-v">
                matplotlib
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                legend
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                Legend
               </span>
               <span class="crayon-i">
                at
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0x7f6a24e2dfd0
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0010 seconds] -->
       <p>
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebgw1eqtpnk8lh8j20b107m3z2.jpg"/>
       </p>
       <p>
        这个图告诉我们，在50个mini-batches的数据之后，我们已经不能再提高验证数据了，因此可以停止训练了。由于训练分数不是很高，我们可能是欠拟合而不是过拟合。要是使用rbf核测试一下就更好了，但是SGDClassifier很不幸的不兼容核技巧。替代方法是可以使用一个多层的感知机，它也可以使用随机梯度下降进行训练，但是一个非线性模型，或者像备忘单建议的，使用核近似法。
       </p>
       <p>
        现在在一个机器学习中使用的经典的解决光学字符识别的数据集上：
       </p>
       <p>
        In [24]:
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a244011414644" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          from sklearn.datasets import load_digits
digits = load_digits(n_class=6)
X = digits.data
y = digits.target
n_samples, n_features = X.shape
print "Dataset consist of %d samples with %d features each" % (n_samples, n_features)

# Plot images of the digits
n_img_per_row = 20
img = np.zeros((10 * n_img_per_row, 10 * n_img_per_row))
for i in range(n_img_per_row):
    ix = 10 * i + 1
    for j in range(n_img_per_row):
        iy = 10 * j + 1
        img[ix:ix + 8, iy:iy + 8] = X[i * n_img_per_row + j].reshape((8, 8))

plt.imshow(img, cmap=plt.cm.binary)
plt.xticks([])
plt.yticks([])
_ = plt.title('A selection from the 8*8=64-dimensional digits dataset')
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a244011414644-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a244011414644-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a244011414644-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a244011414644-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a244011414644-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a244011414644-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a244011414644-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a244011414644-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a244011414644-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a244011414644-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a244011414644-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a244011414644-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a244011414644-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a244011414644-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a244011414644-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a244011414644-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a244011414644-17">
               17
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a244011414644-18">
               18
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a244011414644-19">
               19
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a244011414644-20">
               20
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a244011414644-1">
               <span class="crayon-e">
                from
               </span>
               <span class="crayon-v">
                sklearn
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                datasets
               </span>
               <span class="crayon-e">
                import
               </span>
               <span class="crayon-e">
                load_digits
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a244011414644-2">
               <span class="crayon-v">
                digits
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                load_digits
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                n_class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                6
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a244011414644-3">
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                digits
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-i">
                data
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a244011414644-4">
               <span class="crayon-v">
                y
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                digits
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                target
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a244011414644-5">
               <span class="crayon-v">
                n_samples
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                n_features
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                shape
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a244011414644-6">
               <span class="crayon-i">
                print
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "Dataset consist of %d samples with %d features each"
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                %
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                n_samples
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                n_features
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a244011414644-7">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a244011414644-8">
               <span class="crayon-p">
                # Plot images of the digits
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a244011414644-9">
               <span class="crayon-v">
                n_img_per_row
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                20
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a244011414644-10">
               <span class="crayon-v">
                img
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                zeros
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                10
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                *
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                n_img_per_row
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                10
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                *
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                n_img_per_row
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a244011414644-11">
               <span class="crayon-st">
                for
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-i">
                i
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                in
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                range
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                n_img_per_row
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-o">
                :
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a244011414644-12">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                ix
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                10
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                *
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                i
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a244011414644-13">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                for
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-i">
                j
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                in
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                range
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                n_img_per_row
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-o">
                :
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a244011414644-14">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                iy
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                10
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                *
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                j
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a244011414644-15">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                img
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-v">
                ix
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-v">
                ix
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                8
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                iy
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-v">
                iy
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                8
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-e ">
                i *
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                n_img_per_row
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                j
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                reshape
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                8
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                8
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a244011414644-16">
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a244011414644-17">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                imshow
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                img
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                cmap
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                cm
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                binary
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a244011414644-18">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                xticks
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a244011414644-19">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                yticks
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a244011414644-20">
               <span class="crayon-v">
                _
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                title
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                'A selection from the 8*8=64-dimensional digits dataset'
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0163 seconds] -->
       <p>
        由1083个样本组成的数据集，每个样本由64个特征组成
       </p>
       <p>
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebgw1eqtpnjcb8pj208f06zt9k.jpg"/>
       </p>
       <p>
        因此我们有1083个手写数字（0，1，2，3，4，5）样本，每一个样本由8*8的4bit像素（0，16）灰度图片组成。因此特征的维数适中（64）；但是，这64维空间的可视化是非常重要的。我们来说明不同的减少维数（至二维）方法，基于http://scikit-learn.org/stable/auto_examples/manifold/plot_lle_digits.html#example-manifold-plot-lle-digits-py
       </p>
       <p>
        <code>
         In [25]:
        </code>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a24b695619098" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          # Helper function based on 
# http://scikit-learn.org/stable/auto_examples/manifold/plot_lle_digits.html#example-manifold-plot-lle-digits-py
from matplotlib import offsetbox
def plot_embedding(X, title=None):
    x_min, x_max = np.min(X, 0), np.max(X, 0)
    X = (X - x_min) / (x_max - x_min)

    plt.figure(figsize=(10, 10))
    ax = plt.subplot(111)
    for i in range(X.shape[0]):
        plt.text(X[i, 0], X[i, 1], str(digits.target[i]),
                 color=plt.cm.Set1(y[i] / 10.),
                 fontdict={'weight': 'bold', 'size': 12})

    if hasattr(offsetbox, 'AnnotationBbox'):
        # only print thumbnails with matplotlib &amp;gt; 1.0
        shown_images = np.array([[1., 1.]])  # just something big
        for i in range(digits.data.shape[0]):
            dist = np.sum((X[i] - shown_images) ** 2, 1)
            if np.min(dist) &amp;lt; 4e-3:
                # don't show points that are too close
                continue
            shown_images = np.r_[shown_images, [X[i]]]
            imagebox = offsetbox.AnnotationBbox(
                offsetbox.OffsetImage(digits.images[i], cmap=plt.cm.gray_r),
                X[i])
            ax.add_artist(imagebox)
    plt.xticks([]), plt.yticks([])
    if title is not None:
        plt.title(title)
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a24b695619098-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a24b695619098-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a24b695619098-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a24b695619098-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a24b695619098-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a24b695619098-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a24b695619098-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a24b695619098-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a24b695619098-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a24b695619098-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a24b695619098-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a24b695619098-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a24b695619098-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a24b695619098-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a24b695619098-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a24b695619098-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a24b695619098-17">
               17
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a24b695619098-18">
               18
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a24b695619098-19">
               19
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a24b695619098-20">
               20
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a24b695619098-21">
               21
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a24b695619098-22">
               22
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a24b695619098-23">
               23
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a24b695619098-24">
               24
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a24b695619098-25">
               25
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a24b695619098-26">
               26
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a24b695619098-27">
               27
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a24b695619098-28">
               28
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a24b695619098-29">
               29
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a24b695619098-30">
               30
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a24b695619098-1">
               <span class="crayon-p">
                # Helper function based on
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a24b695619098-2">
               <span class="crayon-p">
                # http://scikit-learn.org/stable/auto_examples/manifold/plot_lle_digits.html#example-manifold-plot-lle-digits-py
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a24b695619098-3">
               <span class="crayon-e">
                from
               </span>
               <span class="crayon-e">
                matplotlib
               </span>
               <span class="crayon-e">
                import
               </span>
               <span class="crayon-e">
                offsetbox
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a24b695619098-4">
               <span class="crayon-e">
                def
               </span>
               <span class="crayon-e">
                plot_embedding
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                title
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-v">
                None
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-o">
                :
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a24b695619098-5">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                x_min
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                x_max
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                min
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                max
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a24b695619098-6">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                x_min
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                x_max
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                x_min
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a24b695619098-7">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a24b695619098-8">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                figure
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                figsize
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                10
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                10
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a24b695619098-9">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                ax
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                subplot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                111
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a24b695619098-10">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                for
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-i">
                i
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                in
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                range
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                shape
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-o">
                :
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a24b695619098-11">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                text
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-v">
                i
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-v">
                i
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                str
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                digits
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                target
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-v">
                i
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a24b695619098-12">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                color
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                cm
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                Set1
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                y
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-v">
                i
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                10.
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a24b695619098-13">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                fontdict
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-sy">
                {
               </span>
               <span class="crayon-s">
                'weight'
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'bold'
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'size'
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                12
               </span>
               <span class="crayon-sy">
                }
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a24b695619098-14">
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a24b695619098-15">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                if
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                hasattr
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                offsetbox
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'AnnotationBbox'
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-o">
                :
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a24b695619098-16">
               <span class="crayon-h">
               </span>
               <span class="crayon-p">
                # only print thumbnails with matplotlib &amp;gt; 1.0
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a24b695619098-17">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                shown_images
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-t">
                array
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-cn">
                1.
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1.
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-p">
                # just something big
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a24b695619098-18">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                for
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-i">
                i
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                in
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                range
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                digits
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                data
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                shape
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-o">
                :
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a24b695619098-19">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                dist
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                sum
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-v">
                i
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                shown_images
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                *
               </span>
               <span class="crayon-o">
                *
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a24b695619098-20">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                if
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                min
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                dist
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                lt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                4e
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                3
               </span>
               <span class="crayon-o">
                :
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a24b695619098-21">
               <span class="crayon-h">
               </span>
               <span class="crayon-p">
                # don't show points that are too close
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a24b695619098-22">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                continue
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a24b695619098-23">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                shown_images
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                r_
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-v">
                shown_images
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-v">
                i
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                ]
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a24b695619098-24">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                imagebox
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                offsetbox
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                AnnotationBbox
               </span>
               <span class="crayon-sy">
                (
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a24b695619098-25">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                offsetbox
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                OffsetImage
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                digits
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                images
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-v">
                i
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                cmap
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                cm
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                gray_r
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a24b695619098-26">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-v">
                i
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a24b695619098-27">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                ax
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                add_artist
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                imagebox
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a24b695619098-28">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                xticks
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                yticks
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a24b695619098-29">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                if
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                title
               </span>
               <span class="crayon-st">
                is
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                not
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                None
               </span>
               <span class="crayon-o">
                :
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a24b695619098-30">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                title
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                title
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0284 seconds] -->
       <p>
        已经随机投影的二维数据的结果不是太差：
       </p>
       <p>
        In [26]:
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a254853230223" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          from sklearn import (manifold, decomposition, random_projection)
rp = random_projection.SparseRandomProjection(n_components=2, random_state=42)
stime = time.time()
X_projected = rp.fit_transform(X)
plot_embedding(X_projected, "Random Projection of the digits (time: %.3fs)" % (time.time() - stime))
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a254853230223-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a254853230223-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a254853230223-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a254853230223-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a254853230223-5">
               5
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a254853230223-1">
               <span class="crayon-e">
                from
               </span>
               <span class="crayon-e">
                sklearn
               </span>
               <span class="crayon-e">
                import
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                manifold
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                decomposition
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                random_projection
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a254853230223-2">
               <span class="crayon-v">
                rp
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                random_projection
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                SparseRandomProjection
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                n_components
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                random_state
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                42
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a254853230223-3">
               <span class="crayon-v">
                stime
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                time
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                time
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a254853230223-4">
               <span class="crayon-v">
                X_projected
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                rp
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                fit_transform
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a254853230223-5">
               <span class="crayon-e">
                plot_embedding
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                X_projected
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "Random Projection of the digits (time: %.3fs)"
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                %
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                time
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                time
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                stime
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0030 seconds] -->
       <p>
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebgw1eqtpnisa7lj20g20gdtcn.jpg"/>
       </p>
       <p>
        然而，有一个很著名的方法一般来说应该适合，也就是PCA（使用TruncatedSVD来实现，不需要构建协方差矩阵）：
       </p>
       <p>
        In [27]:
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a25a719655906" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          X_pca = decomposition.TruncatedSVD(n_components=2).fit_transform(X)
stime = time.time()
plot_embedding(X_pca,
               "Principal Components projection of the digits (time: %.3fs)" % (time.time() - stime))
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a25a719655906-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a25a719655906-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a25a719655906-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a25a719655906-4">
               4
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a25a719655906-1">
               <span class="crayon-v">
                X_pca
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                decomposition
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                TruncatedSVD
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                n_components
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                fit_transform
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a25a719655906-2">
               <span class="crayon-v">
                stime
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                time
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                time
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a25a719655906-3">
               <span class="crayon-e">
                plot_embedding
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                X_pca
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a25a719655906-4">
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "Principal Components projection of the digits (time: %.3fs)"
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                %
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                time
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                time
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                stime
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0022 seconds] -->
       <p>
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebgw1eqtpnic9dlj20g20gd78d.jpg"/>
       </p>
       <p>
        PCA给出一个更好的结果，而且在这个数据集上甚至更快。通过允许64维输入空间到二维目标空间的非线性变换，我们可以得到更好的结果。这有很多种方法；我们这里只介绍一种方法：t-SNE。
       </p>
       <p>
        In [28]:
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a260951252789" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          tsne = manifold.TSNE(n_components=2, init='pca', random_state=0)
stime = time.time()
X_tsne = tsne.fit_transform(X)
plot_embedding(X_tsne,
               "t-SNE embedding of the digits (time: %.3fs)" % (time.time() - stime))
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a260951252789-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a260951252789-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a260951252789-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a260951252789-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a260951252789-5">
               5
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a260951252789-1">
               <span class="crayon-v">
                tsne
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                manifold
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                TSNE
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                n_components
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                init
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                'pca'
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                random_state
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a260951252789-2">
               <span class="crayon-v">
                stime
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                time
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                time
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a260951252789-3">
               <span class="crayon-v">
                X_tsne
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                tsne
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                fit_transform
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a260951252789-4">
               <span class="crayon-e">
                plot_embedding
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                X_tsne
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a260951252789-5">
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "t-SNE embedding of the digits (time: %.3fs)"
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                %
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                time
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                time
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                stime
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0081 seconds] -->
       <p>
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebgw1eqtpnhrmwej20g20gdn00.jpg"/>
       </p>
       <p>
        这是一个非常优秀的嵌入，也表明只使用一个分类器完美地分开这些类是可能的（详见例子http://scikit-learn.org/stable/auto_examples/plot_digits_classification.html）。t-SNE唯一的不足是它需要更多的时间来计算，因此不适用于大数据集（在目前的条件下）
       </p>
       <h2>
        损失函数的选择
       </h2>
       <p>
        损失函数的选择也非常重要。下面是不同损失函数的说明：
        <br/>
        In [29]:
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a267601849937" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          # adapted from http://scikit-learn.org/stable/auto_examples/linear_model/plot_sgd_loss_functions.html
xmin, xmax = -4, 4
xx = np.linspace(xmin, xmax, 100)
plt.plot([xmin, 0, 0, xmax], [1, 1, 0, 0], 'k-',
         label="Zero-one loss")
plt.plot(xx, np.where(xx &amp;lt; 1, 1 - xx, 0), 'g-',
         label="Hinge loss")
plt.plot(xx, np.log2(1 + np.exp(-xx)), 'r-',
         label="Log loss")
plt.plot(xx, np.exp(-xx), 'c-',
         label="Exponential loss")
plt.plot(xx, -np.minimum(xx, 0), 'm-',
         label="Perceptron loss")
# the balanced relative margin machine
#R = 2
#plt.plot(xx, np.where(xx &amp;lt; 1, 1 - xx, (np.where(xx &amp;gt; R, xx-R,0))), 'b-',
#         label="L1 Balanced Relative Margin Loss")
plt.ylim((0, 8))
plt.legend(loc="upper right")
plt.xlabel(r"Decision function $f(x)$")
plt.ylabel("$L(y, f(x))$")
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a267601849937-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a267601849937-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a267601849937-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a267601849937-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a267601849937-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a267601849937-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a267601849937-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a267601849937-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a267601849937-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a267601849937-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a267601849937-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a267601849937-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a267601849937-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a267601849937-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a267601849937-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a267601849937-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a267601849937-17">
               17
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a267601849937-18">
               18
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a267601849937-19">
               19
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a267601849937-20">
               20
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a267601849937-21">
               21
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a267601849937-1">
               <span class="crayon-p">
                # adapted from http://scikit-learn.org/stable/auto_examples/linear_model/plot_sgd_loss_functions.html
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a267601849937-2">
               <span class="crayon-v">
                xmin
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                xmax
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                4
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                4
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a267601849937-3">
               <span class="crayon-v">
                xx
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                linspace
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                xmin
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                xmax
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                100
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a267601849937-4">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                plot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-v">
                xmin
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                xmax
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'k-'
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a267601849937-5">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                label
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "Zero-one loss"
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a267601849937-6">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                plot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                xx
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                where
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                xx
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                lt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                xx
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'g-'
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a267601849937-7">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                label
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "Hinge loss"
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a267601849937-8">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                plot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                xx
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                log2
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                exp
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-v">
                xx
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'r-'
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a267601849937-9">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                label
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "Log loss"
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a267601849937-10">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                plot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                xx
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                exp
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-v">
                xx
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'c-'
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a267601849937-11">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                label
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "Exponential loss"
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a267601849937-12">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                plot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                xx
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                minimum
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                xx
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'm-'
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a267601849937-13">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                label
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "Perceptron loss"
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a267601849937-14">
               <span class="crayon-p">
                # the balanced relative margin machine
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a267601849937-15">
               <span class="crayon-p">
                #R = 2
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a267601849937-16">
               <span class="crayon-p">
                #plt.plot(xx, np.where(xx &amp;lt; 1, 1 - xx, (np.where(xx &amp;gt; R, xx-R,0))), 'b-',
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a267601849937-17">
               <span class="crayon-p">
                #         label="L1 Balanced Relative Margin Loss")
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a267601849937-18">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                ylim
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                8
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a267601849937-19">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                legend
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                loc
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "upper right"
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a267601849937-20">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                xlabel
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-i">
                r
               </span>
               <span class="crayon-s">
                "Decision function $f(x)$"
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a267601849937-21">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                ylabel
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                "$L(y, f(x))$"
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0121 seconds] -->
       <p>
        Out[29]:
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a26d204142840" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          &amp;lt;matplotlib.text.Text at 0x7f6a2879cf90&amp;gt;
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a26d204142840-1">
               1
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a26d204142840-1">
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                lt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-v">
                matplotlib
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                text
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                Text
               </span>
               <span class="crayon-i">
                at
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0x7f6a2879cf90
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0010 seconds] -->
       <p>
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebgw1eqtpnh57k3j20ao07saap.jpg"/>
       </p>
       <p>
        不同的损失函数有不同的优势：
       </p>
       <ul>
        <li>
         0-1损失是在分类问题中你实际上需要的。不幸地是，这是非凸优化问题，由于最优化问题会变得或多或少的不好解决，因此并不实用。
        </li>
        <li>
         合页损失（使用支持向量分类）导出一个在数据中稀疏的解（由于$f(x) &gt; 1$，它变为0），而且对离群点比较稳健（由于$f(x)to-infty$，它仅仅成线性增长）。它不提供充分的校准的概率。
        </li>
        <li>
         对数损失函数（比如，在逻辑回归中使用）导出很好的概率校准。因此，如果你不仅得到二值预测，还可以得出结果的概率，这个损失函数是一个很好的选择。缺点是，它的解在数据空间中是不稀疏的，它比合页损失函数更容易受到离群点的影响。
        </li>
        <li>
         指数损失函数（在Adaboost中使用）非常容易受离群点的影响（由于当$f(x)to-infty$时它快速增加）。它主要适用于Adaboost中，因为它在一个简单有效的boosting算法中有效果。
        </li>
        <li>
         感知器损失函数基本上是合页损失函数的移动版本。合页损失函数也惩罚非常接近边界但是在正确一边的点（间隔最大化准则）。另一方面，感知器损失函数只要数据点在边界正确的一边就可以，如果数据是线性可分就使得边界待定，导致比间隔最大化更差的泛化性。
        </li>
       </ul>
       <h2>
        总结
       </h2>
       <p>
        以上我们讨论了一些怎么让机器学习在一个新的问题上工作起来的建议。我们考虑了分类问题，回归和聚类问题也与之类似。然而，专注于人工数据集（为了便于理解）还有点过于简单化。在很多实际问题中，数据的收集、组织、预处理是极重要的。请参见本文中data wrangling的例子。Pandas是这方面很好的工具。
       </p>
       <p>
        很多应用领域也有具体要求，也有符合这些要求的工具，比如：
       </p>
       <ul>
        <li>
         使用skimage图片处理
        </li>
        <li>
         使用pySPACE的生物信号分析和一般时间序列处理
        </li>
        <li>
         使用pandas处理财务数据
        </li>
       </ul>
       <p>
        我们不详细探索这些领域；然而，寻找一个好的预处理流程往往比选择一个合适的分类器需要付出更大的努力。我们可以通过一个例子初识一个中等复杂的信号处理流程，该例中使用pySPACE在脑电波数据中检测特定事件相关电位：
       </p>
       <p>
        https://github.com/pyspace/pyspace/blob/master/docs/examples/specs/node_chains/ref_P300_flow.yaml
       </p>
       <p>
        信号处理流程包含数据标准化，抽取，带通滤波，降维（xDAWN是一个监督的降维方法），特征提取（局部直线特征），和特征标准化。下图给出了pySPACE中分类之前可用的流程各部分的一个概貌。
       </p>
       <p>
        In [30]:
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a276759973208" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          Image(filename='algorithm_types_detailed.png', width=800, height=600)
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a276759973208-1">
               1
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a276759973208-1">
               <span class="crayon-e">
                Image
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                filename
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                'algorithm_types_detailed.png'
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                width
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                800
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                height
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-cn">
                600
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0009 seconds] -->
       <p>
        Out[30]:
       </p>
       <p>
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebgw1eqtpnh5t3tj20kk0aqtby.jpg"/>
       </p>
       <p>
        机器学习的一个长远目标，也是深度学习领域的追求，是可以学习大部分这样的流程，而不是手工编写它们。
       </p>
       <p>
        In [31]:
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685c8a1a27c421888075" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-mixed-highlight" title="含多种语言">
          </span>
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          %load_ext watermark
%watermark -a "Jan Hendrik Metzen" -d -v -m -p numpy,scikit-learn
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57685c8a1a27c421888075-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57685c8a1a27c421888075-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57685c8a1a27c421888075-3">
               3
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57685c8a1a27c421888075-1">
               <span class="crayon-ta">
                %
               </span>
               <span class="crayon-v">
                load
               </span>
               <span class="crayon-sy">
                _
               </span>
               ext
               <span class="crayon-h">
               </span>
               <span class="crayon-i">
                watermark
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57685c8a1a27c421888075-2">
              </div>
              <div class="crayon-line" id="crayon-57685c8a1a27c421888075-3">
               <span class="crayon-o">
                %
               </span>
               <span class="crayon-v">
                watermark
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-i">
                a
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "Jan Hendrik Metzen"
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-v">
                d
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-v">
                v
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-v">
                m
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-i">
                p
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                numpy
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-v">
                scikit
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-v">
                learn
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0049 seconds] -->
       <p>
        <code>
         Jan Hendrik Metzen 29/01/2015
        </code>
       </p>
       <p>
        CPython 2.7.9
        <br/>
        IPython 2.1.0
       </p>
       <p>
        numpy 1.9.1
        <br/>
        scikit-learn 0.14.1
       </p>
       <p>
        compiler : GCC 4.4.7 20120313 (Red Hat 4.4.7-1)
        <br/>
        system : Linux
        <br/>
        release : 3.16.0-28-generic
        <br/>
        machine : x86_64
        <br/>
        processor : x86_64
        <br/>
        CPU cores : 4
        <br/>
        interpreter: 64bit
       </p>
       <p>
        这篇文章是一篇IPython笔记。你可以
        <a href="https://jmetzen.github.io/notebooks/ml_advice.ipynb" target="_blank">
         下载
        </a>
        该笔记。
       </p>
       <p>
        英文出处：
        <a href="https://jmetzen.github.io/2015-01-29/ml_advice.html" target="_blank">
         jmetzen.github.io
        </a>
       </p>
       <p>
        文章出处：http://www.hotpost.co/16429.html
       </p>
      </div>
      <div>
       <strong>
        注：转载文章均来自于公开网络，仅供学习使用，不会用于任何商业用途，如果侵犯到原作者的权益，请您与我们联系删除或者授权事宜，联系邮箱：contact@dataunion.org。转载数盟网站文章请注明原文章作者，否则产生的任何版权纠纷与数盟无关。
       </strong>
      </div>
      <!--content_text-->
      <div class="fenxian">
       <!-- JiaThis Button BEGIN -->
       <div class="jiathis_style_32x32">
        <p class="jiathis_button_weixin">
        </p>
        <p class="jiathis_button_tsina">
        </p>
        <p class="jiathis_button_qzone">
        </p>
        <p class="jiathis_button_cqq">
        </p>
        <p class="jiathis_button_tumblr">
        </p>
        <a class="jiathis jiathis_txt jtico jtico_jiathis" href="http://www.jiathis.com/share" target="_blank">
        </a>
        <p class="jiathis_counter_style">
        </p>
       </div>
       <!-- JiaThis Button END -->
      </div>
     </article>
     <!--content-->
     <!--相关文章-->
     <div class="xianguan">
      <div class="xianguantitle">
       相关文章！
      </div>
      <ul class="pic">
       <li>
        <a href="http://dataunion.org/20758.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/09/t012aec1078cd96f01f-300x199.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/20758.html" rel="bookmark" title="推荐一些从零开始学习机器学习算法的方法">
         推荐一些从零开始学习机器学习算法的方法
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/20714.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/09/t011650727f6392a3f5-300x197.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/20714.html" rel="bookmark" title="寻找最优参数解：最速下降法，牛顿下降法，阻尼牛顿法，拟牛顿法DFP/BFGS">
         寻找最优参数解：最速下降法，牛顿下降法，阻尼牛顿法，拟牛顿法DFP/BFGS
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/20636.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/09/t01034a6a3b660f0c04_副本-300x203.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/20636.html" rel="bookmark" title="机器学习开发者的现代化攻略：对统计学微积分Say NO！">
         机器学习开发者的现代化攻略：对统计学微积分Say NO！
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/20632.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/08/t01e4f9fea2b69f4b1f-300x189.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/20632.html" rel="bookmark" title="机器学习到底适合哪些人群学习？">
         机器学习到底适合哪些人群学习？
        </a>
       </li>
      </ul>
     </div>
     <!--相关文章-->
     <div class="comment" id="comments">
      <!-- You can start editing here. -->
      <!-- If comments are open, but there are no comments. -->
      <div class="title">
       期待你一针见血的评论，Come on！
      </div>
      <div id="respond">
       <p>
        不用想啦，马上
        <a href="http://dataunion.org/wp-login.php?redirect_to=http%3A%2F%2Fdataunion.org%2F14308.html">
         "登录"
        </a>
        发表自已的想法.
       </p>
      </div>
     </div>
     <!-- .nav-single -->
    </div>
    <!--Container End-->
    <aside id="sitebar">
     <div class="sitebar_list2">
      <div class="wptag">
       <span class="tagtitle">
        热门标签+
       </span>
       <div class="tagg">
        <ul class="menu" id="menu-%e5%8f%8b%e6%83%85%e9%93%be%e6%8e%a5">
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-1605" id="menu-item-1605">
          <a href="http://taidizh.com/">
           泰迪智慧
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20884" id="menu-item-20884">
          <a href="http://www.transwarp.cn/">
           星环科技
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-3538" id="menu-item-3538">
          <a href="http://datall.org/">
           珈和遥感
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20888" id="menu-item-20888">
          <a href="http://www.chinahadoop.cn/">
           小象学院
          </a>
         </li>
        </ul>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <div class="textwidget">
       <div align="center">
        <a href="http://study.163.com/course/courseMain.htm?courseId=991022" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2016/03/dv.jpg"/>
        </a>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       文章分类
      </h4>
      <div class="tagcloud">
       <a class="tag-link-44" href="http://dataunion.org/category/industry/demo" style="font-size: 10.204724409449pt;" title="4个话题">
        Demo展示
       </a>
       <a class="tag-link-31" href="http://dataunion.org/category/experts" style="font-size: 15.826771653543pt;" title="52个话题">
        专家团队
       </a>
       <a class="tag-link-870" href="http://dataunion.org/category/tech/ai" style="font-size: 19.795275590551pt;" title="273个话题">
        人工智能
       </a>
       <a class="tag-link-488" href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f" style="font-size: 8pt;" title="1个话题">
        加入数盟
       </a>
       <a class="tag-link-869" href="http://dataunion.org/category/tech/viz" style="font-size: 17.204724409449pt;" title="93个话题">
        可视化
       </a>
       <a class="tag-link-30" href="http://dataunion.org/category/partners" style="font-size: 10.645669291339pt;" title="5个话题">
        合作伙伴
       </a>
       <a class="tag-link-889" href="http://dataunion.org/category/parterc" style="font-size: 11.582677165354pt;" title="8个话题">
        合作会议
       </a>
       <a class="tag-link-104" href="http://dataunion.org/category/books" style="font-size: 12.96062992126pt;" title="15个话题">
        图书
       </a>
       <a class="tag-link-220" href="http://dataunion.org/category/tech/base" style="font-size: 19.850393700787pt;" title="281个话题">
        基础架构
       </a>
       <a class="tag-link-219" href="http://dataunion.org/category/tech/analysis" style="font-size: 19.409448818898pt;" title="232个话题">
        数据分析
       </a>
       <a class="tag-link-887" href="http://dataunion.org/category/tech/dm" style="font-size: 13.291338582677pt;" title="17个话题">
        数据挖掘
       </a>
       <a class="tag-link-34" href="http://dataunion.org/category/tech" style="font-size: 20.732283464567pt;" title="404个话题">
        文章
       </a>
       <a class="tag-link-1" href="http://dataunion.org/category/uncategorized" style="font-size: 22pt;" title="693个话题">
        未分类
       </a>
       <a class="tag-link-4" href="http://dataunion.org/category/events" style="font-size: 14.503937007874pt;" title="29个话题">
        活动
       </a>
       <a class="tag-link-890" href="http://dataunion.org/category/tech/%e6%b7%b1%e5%ba%a6%e5%ad%a6%e4%b9%a0" style="font-size: 10.204724409449pt;" title="4个话题">
        深度学习
       </a>
       <a class="tag-link-221" href="http://dataunion.org/category/tech/devl" style="font-size: 18.968503937008pt;" title="193个话题">
        编程语言
       </a>
       <a class="tag-link-888" href="http://dataunion.org/category/career" style="font-size: 15.661417322835pt;" title="48个话题">
        职业规划
       </a>
       <a class="tag-link-5" href="http://dataunion.org/category/jobs" style="font-size: 14.11811023622pt;" title="25个话题">
        职位
       </a>
       <a class="tag-link-871" href="http://dataunion.org/category/industry" style="font-size: 15.716535433071pt;" title="49个话题">
        行业
       </a>
       <a class="tag-link-613" href="http://dataunion.org/category/industry/case" style="font-size: 16.984251968504pt;" title="84个话题">
        行业应用
       </a>
       <a class="tag-link-885" href="http://dataunion.org/category/industry/news" style="font-size: 17.425196850394pt;" title="102个话题">
        行业资讯
       </a>
       <a class="tag-link-10" href="http://dataunion.org/category/training" style="font-size: 14.228346456693pt;" title="26个话题">
        课程
       </a>
       <a class="tag-link-16" href="http://dataunion.org/category/sources" style="font-size: 15.661417322835pt;" title="48个话题">
        资源
       </a>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       功能
      </h4>
      <ul>
       <li>
        <a href="http://dataunion.org/wp-login.php?action=register">
         注册
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/wp-login.php">
         登录
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/feed">
         文章
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/comments/feed">
         评论
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="https://cn.wordpress.org/" title="基于WordPress，一个优美、先进的个人信息发布平台。">
         WordPress.org
        </a>
       </li>
      </ul>
     </div>
    </aside>
    <div class="clear">
    </div>
   </div>
   <!--main-->
   ﻿
   <footer id="dibu">
    <div class="about">
     <div class="right">
      <ul class="menu" id="menu-%e5%ba%95%e9%83%a8%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-18024" id="menu-item-18024">
        <a href="http://dataunion.org/category/partners">
         合作伙伴
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20881" id="menu-item-20881">
        <a href="http://dataunion.org/contribute">
         文章投稿
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20872" id="menu-item-20872">
        <a href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f">
         加入数盟
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22441" id="menu-item-22441">
        <a href="http://dataunion.org/f-links">
         友情链接
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20874" id="menu-item-20874">
        <a href="http://dataunion.org/aboutus">
         关于数盟
        </a>
       </li>
      </ul>
      <p class="banquan">
       数盟社区        ，
        做最棒的数据科学社区
      </p>
     </div>
     <div class="left">
      <ul class="bottomlist">
       <li>
        <a href="http://weibo.com/DataScientistUnion  " target="_blank" 　title="">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weibo.png"/>
        </a>
       </li>
       <li>
        <a class="cd-popup-trigger" href="http://dataunion.org/14308.html#0">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weixin.png"/>
        </a>
       </li>
      </ul>
      <div class="cd-popup">
       <div class="cd-popup-container">
        <h1>
         扫描二维码,加微信公众号
        </h1>
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/2014-12-06-1515289049.png"/>
        <a class="cd-popup-close" href="http://dataunion.org/14308.html">
        </a>
       </div>
       <!-- cd-popup-container -->
      </div>
      <!-- cd-popup -->
     </div>
    </div>
    <!--about-->
    <div class="bottom">
     <a href="http://dataunion.org/">
      数盟社区
     </a>
     <a href="http://www.miitbeian.gov.cn/" rel="external nofollow" target="_blank">
      京ICP备14026740号
     </a>
     联系我们：
     <a href="mailto:contact@dataunion.org" target="_blank">
      contact@dataunion.org
     </a>
     <div class="tongji">
     </div>
     <!--bottom-->
     <div class="scroll" id="scroll" style="display:none;">
      ︿
     </div>
    </div>
   </footer>
   <!--dibu-->
  </div>
 </body>
</html>